﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yule8xCommon.Applib;

namespace Yule8xWechat.Other
{
    public partial class WxTest : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string operate = ddlOperate.SelectedValue;
            string url, content;
            switch (operate)
            {
                case "batchget_material":
                    // 获取素材列表
                    url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=" + WechatUtil.GetToken();
                    content = HttpUtil.HttpPost(url, "{'type':'news','offset':0,'count':20}".Replace("'", "\""));
                    Response.Write(Server.HtmlEncode(content));
                    break;
                case "get_material":
                    string mediaid = tb_value1.Text;
                    url = "https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=" + WechatUtil.GetToken();
                    content = HttpUtil.HttpPost(url, "{'media_id':'" + mediaid + "'}".Replace("'", "\""),"utf-8");
                    Response.Write(Server.HtmlEncode(content));
                    break;
            }
        }
    }
}